import { IPSAppDEAction } from '../dataentity/ipsapp-deaction';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSAppUILogicRefView } from './ipsapp-uilogic-ref-view';
import { IPSAppUINewDataLogic } from './ipsapp-uinew-data-logic';
import { PSAppUILogicImpl } from './psapp-uilogic-impl';

export class BuiltinPSAppUINewDataLogicImpl extends PSAppUILogicImpl implements IPSAppUINewDataLogic {
  get actionAfterWizard(): string {
    return this.M.actionAfterWizard;
  }

  protected batchaddpsappdeaction: IPSAppDEAction | null = null;

  getBatchAddPSAppDEAction(): IPSAppDEAction | null {
    if (this.batchaddpsappdeaction != null) return this.batchaddpsappdeaction;
    const value = this.M.getBatchAddPSAppDEAction;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.batchaddpsappdeaction = ipsappdataentity.findPSAppDEAction(value);
    }
    return this.batchaddpsappdeaction;
  }

  get batchAddPSAppDEAction(): IPSAppDEAction | null {
    return this.getBatchAddPSAppDEAction();
  }

  getBatchAddPSAppDEActionMust(): IPSAppDEAction {
    const value = this.getBatchAddPSAppDEAction();
    if (value == null) {
      throw new Error('未指定批添加应用实体方法');
    }
    return value;
  }

  protected batchaddpsappviews: IPSAppUILogicRefView[] | null = null;

  getBatchAddPSAppViews(): IPSAppUILogicRefView[] | null {
    if (this.batchaddpsappviews == null) {
      this.batchaddpsappviews = this.fillChildListModel(this.M.getBatchAddPSAppViews, 'app.logic.IPSAppUILogicRefView') as IPSAppUILogicRefView[];
    }
    return this.batchaddpsappviews;
  }

  get batchAddPSAppViews(): IPSAppUILogicRefView[] | null {
    return this.getBatchAddPSAppViews();
  }

  findBatchAddPSAppUILogicRefView(objKey: any): IPSAppUILogicRefView | null {
    return this.getPSModel5('app.logic.IPSAppUILogicRefView', this.getBatchAddPSAppViews(), objKey) as IPSAppUILogicRefView;
  }

  protected newdatapsappview: IPSAppUILogicRefView | null = null;

  getNewDataPSAppView(): IPSAppUILogicRefView | null {
    if (this.newdatapsappview != null) return this.newdatapsappview;
    const value = this.M.getNewDataPSAppView;
    if (value == null) {
      return null;
    }
    this.newdatapsappview = this.getPSModel4('app.logic.IPSAppUILogicRefView', value, 'getNewDataPSAppView') as IPSAppUILogicRefView;
    return this.newdatapsappview;
  }

  get newDataPSAppView(): IPSAppUILogicRefView | null {
    return this.getNewDataPSAppView();
  }

  getNewDataPSAppViewMust(): IPSAppUILogicRefView {
    const value = this.getNewDataPSAppView();
    if (value == null) {
      throw new Error('未指定默认新建数据视图');
    }
    return value;
  }

  protected newdatapsappviews: IPSAppUILogicRefView[] | null = null;

  getNewDataPSAppViews(): IPSAppUILogicRefView[] | null {
    if (this.newdatapsappviews == null) {
      this.newdatapsappviews = this.fillChildListModel(this.M.getNewDataPSAppViews, 'app.logic.IPSAppUILogicRefView') as IPSAppUILogicRefView[];
    }
    return this.newdatapsappviews;
  }

  get newDataPSAppViews(): IPSAppUILogicRefView[] | null {
    return this.getNewDataPSAppViews();
  }

  findNewDataPSAppUILogicRefView(objKey: any): IPSAppUILogicRefView | null {
    return this.getPSModel5('app.logic.IPSAppUILogicRefView', this.getNewDataPSAppViews(), objKey) as IPSAppUILogicRefView;
  }

  get viewLogicType(): string {
    return this.M.viewLogicType;
  }

  protected wizardpsappview: IPSAppUILogicRefView | null = null;

  getWizardPSAppView(): IPSAppUILogicRefView | null {
    if (this.wizardpsappview != null) return this.wizardpsappview;
    const value = this.M.getWizardPSAppView;
    if (value == null) {
      return null;
    }
    this.wizardpsappview = this.getPSModel4('app.logic.IPSAppUILogicRefView', value, 'getWizardPSAppView') as IPSAppUILogicRefView;
    return this.wizardpsappview;
  }

  get wizardPSAppView(): IPSAppUILogicRefView | null {
    return this.getWizardPSAppView();
  }

  getWizardPSAppViewMust(): IPSAppUILogicRefView {
    const value = this.getWizardPSAppView();
    if (value == null) {
      throw new Error('未指定新建数据向导视图');
    }
    return value;
  }

  get batchAddOnly(): boolean {
    return this.M.batchAddOnly;
  }

  get enableBatchAdd(): boolean {
    return this.M.enableBatchAdd;
  }

  get enableWizardAdd(): boolean {
    return this.M.enableWizardAdd;
  }

  get cls(): string {
    return 'BuiltinPSAppUINewDataLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelObject' || cls == 'IPSObject' || cls == 'app.logic.IPSAppUILogic' || cls == 'app.logic.IPSAppUINewDataLogic' || cls == 'res.IPSSysViewLogic' || cls == 'view.IPSViewLogic')
      return true;
    return super.instanceof(cls);
  }
}
